<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC1001 – This `\o` will be a regular 'o' in this context.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC1001 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC1001">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2 id="this-o-will-be-a-regular-o-in-this-context">This <code>\o</code>
will be a regular 'o' in this context.</h2>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="SC1001.html#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Want literal backslash</span></span>
<span id="cb1-2"><a href="SC1001.html#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> Yay <span class="dt">\o</span>/</span>
<span id="cb1-3"><a href="SC1001.html#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="SC1001.html#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Want other characters</span></span>
<span id="cb1-5"><a href="SC1001.html#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="va">bell</span><span class="op">=</span><span class="dt">\a</span></span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC1001.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="bu">echo</span> <span class="st">&#39;Yay \o/&#39;</span></span>
<span id="cb2-2"><a href="SC1001.html#cb2-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-3"><a href="SC1001.html#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="va">bell</span><span class="op">=</span><span class="st">&quot;</span><span class="va">$(</span><span class="bu">printf</span> <span class="st">&#39;\a&#39;</span><span class="va">)</span><span class="st">&quot;</span></span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>You have escaped something that has no special meaning when escaped.
The backslash will be simply be ignored.</p>
<p>If the backslash was supposed to be literal, single quote or escape
it.</p>
<p>If you wanted it to expand to something, rewrite the expression to
use <code>printf</code> (or in bash, <code>$'\t'</code>). If the
sequence in question is <code>\n</code>, <code>\t</code> or
<code>\r</code>, you instead get a <a href="SC1012.html">SC1012</a> that
describes this.</p>
<h3 id="exceptions">Exceptions</h3>
<p>None. ShellCheck (as of <a
href="https://github.com/koalaman/shellcheck/commit/31bb02d6b794f248f732643d744f63bec615b1f7">2017-07-03</a>,
commit <a
href="https://github.com/koalaman/shellcheck/commit/31bb02d6b794f248f732643d744f63bec615b1f7"><code>31bb02d6</code></a>)
will not warn when the first letter of a command is unnecessarily
escaped, as this is frequently used to suppress aliases
interactively.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


